Vue.component("showcom", {
  data() {
    return {
      tabledata: [],
      vstr: ""
    }
  },
  props: ["path", "col", "showitem", "pval", "vt"],
  template: `<div style="margin:20px;">
      <el-button type="primary" plain @click="opendata()">查询</el-button>
      <pre>{{vstr}}</pre>
      <el-table :data="tabledata" style="width: 100%" @cell-click="cellclick">
        <el-table-column v-for="(item,index) in col" :key="index" :prop="index" :label="item" sortable ></el-table-column>
      </el-table>
    </div>`,
  methods: {
    opendata: function () { //请求数据
      //console.log("opendata", this, this.path, this.datebe);
      let $this = this;
      if (this.vstr) this.vstr = "";
      http.get("/ajax/" + this.path).then(function (res) {
        if ("view" in res.data) {
          $this.vstr = res.data.view;
          $this.tabledata = res.data.data;
        } else {
          $this.tabledata = res.data;
        }
      });
    },
    cellclick: function (row, col, cell) { //点击了单元格
      if (this.col["usrid"] == "UserID" && cell.cellIndex == 0) {
        console.log("UserID", cell.innerText);
        this.$emit('showmenu', 0, 1, cell.innerText);
      }
    }
  }
});